package com.lh.tams.service.system;

import java.util.List;

import org.springframework.stereotype.Service;

import com.lh.tams.dao.system.TimeDao;
import com.lh.tams.domain.TamsTime;
import com.lh.tams.util.DataGridModel;
import com.lh.tams.util.Global;
import com.lh.tams.util.Page;
import com.lh.tams.util.Status;

/**
 * 时限Service
 * @author liulin
 * @version 2012-11-18
 */
@Service
public class TimeService {
	private TimeDao timeDao;
	
	public TimeDao getTimeDao() {
		return timeDao;
	}

	public void setTimeDao(TimeDao timeDao) {
		this.timeDao = timeDao;
	}

	public Page query(DataGridModel dgm,TamsTime tamsTime){
		return timeDao.query(dgm, tamsTime);
	}
	
	public void add(TamsTime tamsTime){
		timeDao.add(tamsTime);
	}
	
	public void update(TamsTime tamsTime){
		timeDao.update(tamsTime);
	}
	
	public void delete(long[] ids){
		timeDao.delete(ids);
	}
	
	public void flash(){
		Page page = timeDao.query(new DataGridModel(), new TamsTime());
		List<TamsTime> times = (List<TamsTime>)page.getRows();
		for(TamsTime time:times){
			if(time.getDealType()==Status.CASE_DEAL_COMMON && time.getFlowName()==Status.FLOW_REGISTER){
				Global.COMMON_REGISTER = time.getTimeDay();
				continue;
			}
			if(time.getDealType()==Status.CASE_DEAL_COMMON && time.getFlowName()==Status.FLOW_INDENTIY){
				Global.COMMON_IDENTIFY = time.getTimeDay();
				continue;
			}
			if(time.getDealType()==Status.CASE_DEAL_COMMON && time.getFlowName()==Status.FLOW_CONFIRM){
				Global.COMMON_CONFIRM = time.getTimeDay();
				continue;
			}
			if(time.getDealType()==Status.CASE_DEAL_COMMON && time.getFlowName()==Status.FLOW_DEAL){
				Global.COMMON_DEAL = time.getTimeDay();
				continue;
			}
			if(time.getDealType()==Status.CASE_DEAL_COMMON && time.getFlowName()==Status.FLOW_RECORD){
				Global.COMMON_RECORD = time.getTimeDay();
				continue;
			}
			if(time.getDealType()==Status.CASE_DEAL_SIMPLE && time.getFlowName()==Status.FLOW_CONFIRM){
				Global.SIMPLE_CONFIRM = time.getTimeDay();
				continue;
			}
			if(time.getDealType()==Status.CASE_DEAL_SIMPLE && time.getFlowName()==Status.FLOW_DEAL){
				Global.SIMPLE_DEAL = time.getTimeDay();
				continue;
			}
			if(time.getDealType()==Status.CASE_DEAL_SIMPLE && time.getFlowName()==Status.FLOW_RECORD){
				Global.SIMPLE_RECORD = time.getTimeDay();
				continue;
			}
		}
		
	}
}
